package com.webchat.client.mall.controller.im;


import com.webchat.client.mall.service.im.MallChatAccountService;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.config.annotation.ValidateLogin;
import com.webchat.common.helper.SessionHelper;
import com.webchat.domain.vo.response.mall.im.MallChatListItemResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mall-service/im/account")
public class MallChatAccountController {


    @Autowired
    private MallChatAccountService mallChatAccountService;

    /**
     * 商家智能客服对话账号列表接口
     *
     * @param chatAccount
     * @param lastTime
     * @param size
     * @return
     */
    @ValidateLogin
    @GetMapping("/list")
    public APIResponseBean<List<MallChatListItemResponseVO>> list(
            @RequestParam(value = "chatAccount", required = false) String chatAccount,
            @RequestParam(value = "lastTime", required = false) Long lastTime,
            @RequestParam(value = "size", required = false, defaultValue = "10") int size) {

        String account = SessionHelper.getCurrentUserId();
        List<MallChatListItemResponseVO> accountList = mallChatAccountService.list(account, chatAccount, lastTime, size);
        return APIResponseBeanUtil.success(accountList);
    }
}
